<?php

namespace app\admin\controller;

use think\Controller;
use app\admin\model\Admin;

class Index extends Controller{
    //首页
    public function index(){
        if(empty(session('username')))
        {
            $this->error('请先登录','login/login');
        }
        $result = Admin::get(session('username'));
        $username = session('username');
        $this->assign('username',$username);
        return $this->fetch();
    }

    // 欢迎页面
    public function welcome(){
        if(empty(session('username')))
        {
            $this->error('请先登录','login/login');
        }
        $result = Admin::get(session('username'));
        $username = session('username');
        $this->assign('username',$username);
        return $this->fetch();
    }

    //展示个人信息
    public function selfInfo(){
        if(empty(session('username')))
        {
            $this->error('请先登录','login/login');
        }
        $result = Admin::get(session('username'));
        $username = session('username');
        $authority = $result->authority;
        $this->assign('username',$username);
        $this->assign('auth',$authority);
        return $this->fetch();
    }
}
